package com.sangengblog.controller;


import com.sangengblog.domain.ResponseResult;
import com.sangengblog.domain.dto.ChangeStatusDto;
import com.sangengblog.domain.entity.Menu;
import com.sangengblog.domain.entity.Role;
import com.sangengblog.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/system/role")
public class RoleController {

    @Autowired
    private RoleService roleService;

    @GetMapping("/list")
    public ResponseResult list(int pageNum,int pageSize,String roleName,String status) {
        return roleService.list(pageNum, pageSize, roleName, status);
    }

    @PutMapping("/changeStatus")
    public ResponseResult changeStatus(@RequestBody ChangeStatusDto changeStatusDto) {
        return roleService.changeStatus(changeStatusDto);
    }

    @PostMapping
    public ResponseResult addRole(@RequestBody Role role) {
        return roleService.addRole(role);
    }

    @GetMapping("/{id}")
    public ResponseResult getRoleInfo(@PathVariable Long id) {
        return roleService.getRoleInfo(id);
    }

    @PutMapping
    public ResponseResult updateRole(@RequestBody Role role) {
        return roleService.updateRole(role);
    }

    @DeleteMapping("/{id}")
    public ResponseResult deleteRole(@PathVariable Long id) {
        return roleService.deleteRole(id);
    }

    @GetMapping("/listAllRole")
    public ResponseResult listAllRole() {
        return roleService.listAllRole();
    }
}
